<!doctype html>
<html class="no-js" lang="zxx">

	<head>
		<meta charset="utf-8">
		<meta http-equiv="x-ua-compatible" content="ie=edge">
		<title>商品添加</title>
		<meta name="robots" content="noindex, follow" />
		<meta name="description" content="">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<!-- Favicon -->


		<!-- CSS
	============================================ -->

		<!-- Bootstrap CSS -->
		<link rel="stylesheet" href="assets/css/vendor/bootstrap.min.css">
		<!-- Fontawesome -->
		<link rel="stylesheet" href="assets/css/vendor/font-awesome.css">
		<!-- Fontawesome Star -->
		<link rel="stylesheet" href="assets/css/vendor/fontawesome-stars.css">
		<!-- Ion Icon -->
		<link rel="stylesheet" href="assets/css/vendor/ion-fonts.css">
		<!-- Slick CSS -->
		<link rel="stylesheet" href="assets/css/plugins/slick.css">
		<!-- Animation -->
		<link rel="stylesheet" href="assets/css/plugins/animate.css">
		<!-- jQuery Ui -->
		<link rel="stylesheet" href="assets/css/plugins/jquery-ui.min.css">
		<!-- Venobox.css -->
		<link rel="stylesheet" href="assets/css/plugins/venobox.css">
		<!-- Nice Select -->
		<link rel="stylesheet" href="assets/css/plugins/nice-select.css">

		<!-- Vendor & Plugins CSS (Please remove the comment from below vendor.min.css & plugins.min.css for better website load performance and remove css files from the above) -->
		<!--
    <link rel="stylesheet" href="assets/css/vendor/vendor.min.css">
    <link rel="stylesheet" href="assets/css/plugins/plugins.min.css">
    -->

		<!-- Main Style CSS (Please use minify version for better website load performance) -->
		<link rel="stylesheet" href="assets/css/style.css">
		<!--<link rel="stylesheet" href="assets/css/style.min.css">-->

	</head>

	<body class="template-color-1">
		<div class="main-wrapper">
			<div class="loading">
				<div class="text-center middle">
					<span class="loader">
						<span class="loader-inner"></span>
					</span>
				</div>
			</div>
		</div>
		</header>
		<div class="compare-area">
			<div class="container">
				<div class="compare-table table-responsive">
					<table class="table table-bordered table-hover mb-0" id="btb">
						<form id="product_add">
						<tbody>
							<tr>
								<th class="compare-column-titles">封面图片</th>
								<td class="compare-column-productinfo">
									<div class="compare-pdoduct-image">
										<img id="showcover">
									</div>
								</td>
							</tr>
							<tr>
								<th class="compare-column-titles">加入图片</th>
								<td class="compare-column-productinfo">
									<div class="compare-pdoduct-image">
										<input type="file" accept="image/*" id="procover" name="procover" class="umino-compare_btn" style="height: 48.5px; margin-top: -6px;">
									</div>
								</td>
							</tr>
							<tr>
								<th>详细图片</th>
								<td>
									<div class="compare-pdoduct-image">
										<input type="file" multiple accept="image/*" id="imgadd" name="imgadd" class="umino-compare_btn" style="height: 48.5px; margin-top: -5px;">
									</div>
								</td>
							</tr>
							<tr>
								<th>商品名称</th>
								<td>
									<input type="text" placeholder="输入商品名称" id="proname" name="proname">
								</td>
							</tr>
							<tr>
								<th>价格</th>
								<td><input type="text" placeholder="输入商品价格" id="proprice" name="proprice"></td>
							</tr>
							<tr>
								<th>折扣</th>
								<td><input type="text" placeholder="设置商品折扣 格式为0.?" id="prosallery" name="prosallery"></td>
							</tr>
							<tr>
								<th>种类</th>
								<td><input type="text" placeholder="设置商品种类" id="protype" name="protype"></td>
							</tr>
							<tr>
								<th>规格</th>
								<td><input type="text" placeholder="设置商品规格" id="prospec" name="prospec"></td>
							</tr>
							<tr>
								<th>商品简介</th>
								<td>
									<textarea type="text" placeholder="输入商品简介" style="resize: none;" id="prodescribes" name="prodescribes"></textarea>
								</td>
							</tr>
						</tbody>
					</table>
					</form>
				</div>
			</div>
			<div class="newsletter-form_wrap" id="tjan">
				<div id="mc-form" class="mc-form subscribe-form">
					<button class="newsletter-btn" id="mc-submit">确认</button>
				</div>
			</div>
		</div>
		
		<div class="umino-footer_area" id="zxf">
			<div class="footer-top_area bg--tangerine_yellow">
				<div class="container">
					<div class="row">
						<div class="col-lg-6">
							<div class="newsletter-area">
								<div class="newsletter-info">
									<i class="fa fa-paper-plane" aria-hidden="true"></i>
									<span>Subscribe Newsletter And Get Discount</span>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		</div>
		<!-- jQuery JS -->
		<script src="assets/js/vendor/jquery-1.12.4.min.js"></script>
		<script src="assets/js/vendor/bootstrap.min.js"></script>

		<!-- Slick Slider JS -->
		<script src="assets/js/plugins/slick.min.js"></script>
		<script src="assets/js/plugins/jquery.barrating.min.js"></script>
		<!-- Counterup JS -->
		<script src="assets/js/plugins/jquery.counterup.js"></script>
		<!-- Nice Select JS -->
		<script src="assets/js/plugins/jquery.nice-select.js"></script>
		<!-- Sticky Sidebar JS -->
		<script src="assets/js/plugins/jquery.sticky-sidebar.js"></script>
		<!-- jQuery UI -->
		<script src="assets/js/plugins/jquery-ui.min.js"></script>
		<!-- jQuery UI Touch Punch -->
		<script src="assets/js/plugins/jquery.ui.touch-punch.min.js"></script>
		<!-- Venobox JS -->
		<script src="assets/js/plugins/venobox.min.js"></script>
		<!-- Scroll Top JS -->
		<script src="assets/js/plugins/scroll-top.js"></script>
		<!-- Theia Sticky Sidebar JS -->
		<script src="assets/js/plugins/theia-sticky-sidebar.min.js"></script>
		<!-- Waypoints JS -->
		<script src="assets/js/plugins/waypoints.min.js"></script>
		<!-- ElevateZoom JS -->
		<script src="assets/js/plugins/jquery.elevateZoom-3.0.8.min.js"></script>
		<script src="assets/js/main.js"></script>
		<script src="js/index.js"></script>
		<script src="js/layer/layer.js"></script>

	</body>
<script>
	$(function () {
		var propriceflag =false;
		var prosalleryflag =false;
		var propricereg=/^\d+[.]*\d+$/;
		var prosalleryreg=/^[0|1]{1}[.]{1}\d+$/
		$('#proprice').blur(function () {
			if(!propricereg.test($('#proprice').val())){
				layer.tips("价格有误",'#proprice',{tips:[2,'#ff2040'],time:1000})
			}else {
				propriceflag=true;
			}});
		$('#prosallery').blur(function () {
			if(!prosalleryreg.test($('#prosallery').val())){
				layer.tips("格式有误",'#prosallery',{tips:[2,'#ff2040'],time:1000})
			}else {
				prosalleryflag=true;
			}});
		$('#procover').on('change',function(){
			var file =this.files[0];
			var reader =new FileReader;
			reader.onload =function(e){
				$('#showcover').attr('src',e.target.result)
			}
			reader.readAsDataURL(file);
		});
		$("#mc-submit").click(function(){
			if($('#proname').val()!='' && $('#proprice').val()!='' && $('#prosallery').val()!='' && $('#protype').val()!='' && $('#prospec').val()!='' && $('#prodescribes').val()!=''){
			if(propriceflag && prosalleryflag){
				if($('#procover').val()==null || $('#procover').val()=="" ||$('#imgadd').val()== null || $('#imgadd').val()==""){
                  layer.msg("还未插入封面图与详细图片",{time: 1000});
                  return;
				}else {
			var formdata =new FormData($("#product_add").get(0));
			$.ajax({
				url:'add_product.do',
				data:formdata,
				type:'post',
				dataType:'json',
				processData:false,
				contentType:false,
			}).done(function(data){
				layer.msg(data.msg,{icon:1,time:1000},function () {
					location.href="index.html";
				})
			}).fail(function(){});
			}
			}else{
				layer.msg("请修正价格和折扣",{time: 1000});
			}
			}else {
				layer.msg("请输入完整信息",{time: 1000});
				return;
			}
		})

	})
</script>
</html>
